export const MoveStart = (event, MoveCache, scale = 1, MoveEvent, MoveEnd) => {
    const Cache = {
        x: event.clientX,
        y: event.clientY,
    };

    const _MoveCache = {
        x: MoveCache.x,
        y: MoveCache.y,
    };

    const _MoveEvent = (event) => {
        var x = _MoveCache.x + (event.clientX - Cache.x) / scale;
        var y = _MoveCache.y + (event.clientY - Cache.y) / scale;
        MoveEvent(x, y, (event.clientX - Cache.x) / scale, (event.clientY - Cache.y) / scale);
        return { x, y };
    };

    const _MoveEnd = (event) => {
        // console.log("end");
        var _data = _MoveEvent(event);
        MoveEnd(_data.x, _data.y);
        document.removeEventListener("mousemove", _MoveEvent);
        document.removeEventListener("mouseup", _MoveEnd);
    };

    document.addEventListener("mousemove", _MoveEvent);
    document.addEventListener("mouseup", _MoveEnd);
};
